<template>
  <div class="list-content">
    <!-- 标题 -->
    <h4 class="list-title"> { { newsListInfo.title } }

    </h4>
    <!-- 添加事件、点击次数 -->
    <p class="list-addTime">
      <span> { { newsListInfo.add_time | dataFormat } }

      </span>
      <span>点击： { { newsListInfo.click } } 次

      </span>
    </p>
    <hr>
    <!-- 内容区 -->
    <div class="list-info" v-html="newsListInfo.content"></div>
    <!-- 评论区 -->
    <comment-info></comment-info>
  </div>
</template>
<script>
import { Toast } from "mint-ui";
import comment from "../subcomponents/comment.vue";
export default {
  data() {
    return {
      newsListInfo: ""
    };
  },
  created() {
    this.getId();
  },
  methods: {
    getId() {
      const id = this.$route.params.id; // 拿到 URL 地址中的 id。
      this.$http({
        method: "get",
        url: "api/getnew/" + id,
        data: id
      }).then(
        res => {
          if (res.body.status === 0) {
            this.newsListInfo = res.body.message[0];
          }
        },
        res => {
          Toast("请求失败，请重试");
        }
      );
    }
  },
  components: {
    "comment-info": comment
  }
};
</script>
<style lang="less">
.list-content {
  padding: 2px 3px;
  .list-title {
    color: red;
    font-size: 14px;
  }
  img {
    width: 100%;
    height: 100%;
  }
  .list-addTime {
    color: blue;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
  }
}
</style>